<script type="text/javascript">
  <%
    if( system.GetSessionVar("sessionTAB") != "control/devices" )
    {
      system.SetSessionVar("sessionTAB", "control/devices");
      system.SetSessionVar("sessionTAB1", "");
    }
  %>
  //setPath("<span onclick='WebUI.enter(ControlPage);'>Status und Bedienung</span> &gt; Ger�te");
  setPath("<span onclick='WebUI.enter(ControlPage);'>"+translateKey('menuControlPage') +"</span> &gt; " +translateKey('submenuDevices'));
  fltDL = new iseFilter('fltDL');
  fltHD = new iseFilter('fltHD');
  arItems = new Array();
</script>

<div id="devicepage" class="CLASS03900">
    <!-- Linke Spalte -->
    <div id="contentLeft" class="hidden">
      <table class="filterTable CLASS03901 j_translate" cellpadding="0" cellspacing="0">
        <tr>
          <td style="vertical-align: top; border: 0px">
            <div id="divDL" class="CLASS03902">
              <table id="tblFunctionNames" class="StatViewTbl CLASS03903 j_translate" cellpadding="0" cellspacing="0" style="width:100%;">
                <colgroup>
                  <col style="width:80%;"/>
                  <col style="width:20%;"/>
                </colgroup>
                <tr>
                  <th>${thName}</th>
                  <th>${thPicture}</th>
                </tr>
                <tbody>
                <tr>
                  <td class="CLASS03501">
                    <div id="btnFilterDevName" class="FilterBtn">${thFilter}</div>
                    <div class="FilterSubMenu" id="btnFilterDevNameSub" style="display:none">
                      <input id="ftDevName" onkeypress="iseSFilterCheckEnterEsc(event.keyCode, 'ftSetDevNameBtn', 'ftCancelDevNameBtn')" type="text" size="15" class="CLASS03307" />
                      <div id="ftSetDevNameBtn" class='FilterSetButton CLASS03504' onclick="setSFilter(fltDL, 'ftDevName', FIL_NAME);updateDevTable();$('btnFilterDevNameSub').hide();" >${filterSet}</div>
                      <div id="ftCancelDevNameBtn" class='FilterSetButton' onclick="$('btnFilterDevNameSub').hide();">${filterClose}</div>
                    </div>
                  </td>
                  <td class="CLASS03304"></td>
                </tr>
                <%
                  object obj = dom.GetObject(ID_DEVICES);
                  if ( obj )
                  {
                    obj.SortByName(soAsc,stNatural);
                    string tmp = "";
                    string sFirstId = "";
                    foreach( tmp, obj.EnumEnabledIDs() )
                    {
                      object devs = dom.GetObject(tmp);
                      string s1;
                      foreach( s1, devs.Channels().EnumEnabledVisibleIDs() )
                      {
                        object oCH = dom.GetObject( s1 );
                        if( oCH )
                        {
                          boolean bHasFullAccess = (oCH.UserAccessRights(iulOtherThanAdmin) == iarFullAccess);
                          boolean bHasDPs = (oCH.DPs().EnumEnabledVisibleIDs().Length());
                          boolean bDefaultDPWrite = (oCH.DefaultDPWrite()!=ID_ERROR);
                          boolean bIsSysVarDP = false;
                          object oTmpDP = dom.GetObject( oCH.DefaultDPWrite() );
                          if( oTmpDP )
                          {
                            bIsSysVarDP = ( oTmpDP.IsTypeOf( OT_VARDP ) || oTmpDP.IsTypeOf( OT_ALARMDP ) );
                          }
                        }
                      }
                      if(devs.Visible()
                        && devs.ReadyConfig()
                        && devs.HssType()
                        && (! devs.MetaData("operateGroupOnly") == "true" )
                        && (devs.HssType() != "VIR-OL-GTW")
                        && (devs.HssType() != "VIR-HUE-GTW")
                      )
                        {
                        if( sFirstId == "" )
                        {
                          sFirstId = tmp;
                        }
                        string trId = "devices"#devs.ID();
                        WriteLine('<tr id="'#trId#'" class="CLASS03904">');
                          Write("<td id='"#devs.ID()#"name' class='ButtonStatusRooms CLASS03905' onclick='fltHD.clearFilters();updateTable();loadChannels("#devs.ID()#")' onmouseover='this.addClassName(\"DeviceListRow_Highlight\")' onmouseout='this.removeClassName(\"DeviceListRow_Highlight\")'>");
                          Write(devs.Name());
                          Write("</td>");
                          Write("<td id='"#devs.ID()#"pic' class='ButtonStatusRoomsPic CLASS03906' onclick='picDivHide(jg_250);DeviceListPage.showConfiguration(event, \"DEVICE\", "# devs.ID() #");' onmouseover='this.addClassName(\"DeviceListRow_Highlight\")' onmouseout='this.removeClassName(\"DeviceListRow_Highlight\")'>");
                          
                          string sPicDivId = "picDiv"#devs.ID();
                          Write("<div id='"#sPicDivId#"' class='CLASS03907' style='margin:auto;' ");
                            Write("onmouseover='picDivShow(jg_250, \""#devs.Label()#"\", 250, -1, this);'");
                            Write("onmouseout='picDivHide(jg_250);'");
                          Write("></div>");
                          
                          Write("<script type='text/javascript'>");   
                          Write("var jg_0 = new jsGraphics('"#sPicDivId#"');");
                            Write("InitGD(jg_0, 50);");
                            Write("Draw(jg_0, '"#devs.Label()#"', 50, '-1');");
                          Write("var tmp = new Object();");
                          Write("tmp['name'] = '"#devs.Name()#"';");
                          Write("tmp['trid'] = '"#trId#"';");
                          Write("arItems[arItems.length] = tmp;");
                          Write("Cursor.set(Cursor.NORMAL);");
                          Write("</script>");
                          
                          Write("</td>");
                        Write("</tr>");
                      }
                    }
                  }
                %>
              </table>
            </div>
          </td>
       </tr> 
     </table>
   </div>

    <!-- Rechte Spalte -->
    <div id="contentRight">
      <div id="divRTD" class="CLASS03908">
        <table id="tblRightContent" class="CLASS03909" cellpadding="0" cellspacing="0">
         <tr class="CLASS03910">
           <td style="vertical-align: top;" id="chnList"></td>
         </tr>
        </table>
      </div>
    </div>
</div>
<script type="text/javascript">
       
  loadChannels = function(id, specialFlag)
  {

    // Introduced with the blind.fn
    if (! specialFlag) {
      jQuery('body').data('loadCh_'+id, false );
    }

    iseInitUpdateArrays();
    if( id )
    {
      // aktuellen Markierung aufheben
      var tdlist = $("tblFunctionNames").getElementsByTagName('td');
      for (var i = 0; i < tdlist.length; i++)
      {
        $(tdlist[i]).removeClassName("ButtonStatusRoomsSelected");
        $(tdlist[i]).removeClassName("ButtonStatusRoomsPicSelected");
      }
      
      // Markierung setzen
      $(id + "name").addClassName("ButtonStatusRoomsSelected");
      $(id + "pic").addClassName("ButtonStatusRoomsPicSelected");
      
      // Inhalt nachladen
      var pb = '';
      pb += 'integer id = '+id+';';
      var opts = 
      {
        postBody: pb,
        evalScripts: true
      };
      new Ajax.Updater("chnList", "/pages/tabs/control/hdevichannels.htm?sid=" + SessionId, opts);
    }
    else
    {
      if(dbg)alert(translateKey("alertIDnotSet") + " (control/devices.htm)");
    }
  }
  
  // Beim laden der Seite ersten Raum anzeigen
  <%
    if( system.GetSessionVar("sessionTAB1") == "" )
    {
      system.SetSessionVar("sessionTAB1",sFirstId);
    }
  %>
  loadChannels( <% Write( system.GetSessionVar("sessionTAB1") ); %> );
  
  filterOptions = new iseFilter();
</script>

<script type="text/javascript">
  ShowInternalDeviceChannels = function()
  {
    var url = '/esp/system.htm?sid='+SessionId;
    var pb = "";
    pb += 'string action = "ShowInternalDeviceChannels";';
    var opt =
    {
      postBody: pb,
      onComplete: function(t)
      {
        if(dbg){alert(t.responseText);}
        reloadPage();
      }
    };
    new Ajax.Request(url,opt);
  };

  <%
    string sInternalBtnText = "";
    if( system.GetSessionVar("sessionSIDC") == "1" )
    {
        !sInternalBtnText = "aus";
        sInternalBtnText = "footerBtnHideInternalDeviceChannels";
    }
    else
    {
        !sInternalBtnText = "ein";
        sInternalBtnText = "footerBtnShowInternalDeviceChannels";
    }
    Write("var internalBtnText = '"#sInternalBtnText#"';");
  %>

  var s = "";

  var mouseOpts =
  {
    onTopOver: function(divToShow)
    {
      selectFilters(fltDL, divToShow);
    }
  };

  new iseSubMenuControl("btnFilterDevName", "btnFilterDevNameSub", "contentLeft", {d:28, r:18}, mouseOpts, false, true);

  jQuery("#btnFilterDevName").click(function(){
    jQuery("#ftDevName").focus();
  });

  s += "<table cellspacing='8'>";
  s += "<tr>";
  s += "<td style='text-align:center; vertical-align: middle;'><div class='FooterButton' onclick='WebUI.goBack()'>"+translateKey("footerBtnPageBack")+"</div></td>";
  s += "<td style='text-align:center; vertical-align: middle;'><div class='FooterButton CLASS03911' onclick='fltDL.clearFilters();updateDevTable();fltHD.clearFilters();updateTable();clearInputLeft();'>"+translateKey('footerBtnResetFilter')+"</div></td>";
  s += "<td style='text-align:center; vertical-align: middle;'><div class='FooterButton CLASS04905' onclick='ShowInternalDeviceChannels()'>"+translateKey(internalBtnText)+"</div></td>";
  s += "</tr>";
  s += "</table>";
  
  setFooter(s);
  
  updateTable = function()
  {
    colorFilterBtns(fltHD);
    for (var i = 0; i < arChns.length; i++)
    {
      if (!fltHD.objPassFilter(arChns[i]))
      {
        hide(arChns[i]['trid']);
        if (arChns[i]['ctrlId']) hide(arChns[i]['ctrlId']);
      }
      else
      {
        show(arChns[i]['trid']);
        if (arChns[i]['ctrlId']) show(arChns[i]['ctrlId']);
      }
    }
  };

  updateDevTable = function()
  {
    colorFilterBtns(fltDL);
    for (var i = 0; i < arItems.length; i++)
    {
      if (!fltDL.objPassFilter(arItems[i]))
      {
        hide(arItems[i]['trid']);
      }
      else
      {
        show(arItems[i]['trid']);
      }
    }
  };

  clearInputLeft = function()
  {
    document.getElementById("ftDevName").value = "";
  };
  translatePage("#contentLeft");
  jQuery("#contentLeft").removeClass("hidden");
</script> 
